package com.company.Hard;

import java.util.*;

public class LK451 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String s = scanner.nextLine();
        Map<Character, Integer> map = new HashMap<Character, Integer>();
        int length = s.length();
        for (int i = 0; i < length; i++) {
            char c = s.charAt(i);
            int frequency = map.getOrDefault(c, 0) + 1;
            map.put(c, frequency);
        }
        List<Character> list = new ArrayList<Character>(map.keySet());
        Collections.sort(list, (a, b) -> map.get(b) - map.get(a));
        StringBuffer sb = new StringBuffer();
        int size = list.size();
        for (int i = 0; i < size; i++) {
            char c = list.get(i);
            int frequency = map.get(c);
            for (int j = 0; j < frequency; j++) {
                sb.append(c);
            }
        }
        System.out.println(sb.toString());
    }


    public String frequencySort(String s) {
        char[] arr = s.toCharArray();
        List<Character> list = new ArrayList<>();
        HashMap<Character,Integer> map = new HashMap<>();
        for(int i =0;i<arr.length;i++){
            if(map.containsKey(arr[i])){
                map.put(arr[i],map.get(arr[i])+1);
            }else{
                map.put(arr[i],1);
                list.add(arr[i]);
            }
        }
        Collections.sort(list,(a,b)->map.get(b)-map.get(a));

        StringBuilder stringBuilder = new StringBuilder();
        for(int i =0;i<list.size();i++){
            for(int j=0;j<map.get(list.get(i));j++){
                stringBuilder.append(list.get(i));
            }
        }
        return stringBuilder.toString();
    }
}
